﻿@model Telerik.Web.Mvc.GridModel<TaxCategoryModel>
@using Telerik.Web.Mvc.UI;
@using System.Linq;
@{    
    ViewBag.Title = T("Admin.Configuration.Tax.Categories").Text;
}
<div class="section-header">
    <div class="title">
        @T("Admin.Configuration.Tax.Categories")
    </div>
</div>
<div>
	@(Html.Telerik().Grid<TaxCategoryModel>(Model.Data)
			.Name("taxcategory-grid")
			.DataKeys(x =>
			{
				x.Add(y => y.Id).RouteKey("Id");
			})
			.Columns(columns =>
			{
				columns.Bound(x => x.Name)
					.Width("70%");
				columns.Bound(x => x.DisplayOrder)
					.Centered()
					.Width("10%");
				columns.Command(commands =>
				{
					commands.Edit().Localize(T);
					commands.Delete().Localize(T);
				})
				.HtmlAttributes(new { align = "right",  @class= "omega" })
				.Width("20%");
			})
			.DataBinding(dataBinding =>
			{
				dataBinding.Ajax().Select("Categories", "Tax")
					.Update("CategoryUpdate", "Tax")
					.Delete("CategoryDelete", "Tax")
					.Insert("CategoryAdd", "Tax");
			})
			.ToolBar(x => x.Insert())
			.Editable(x => { x.Mode(GridEditMode.InLine); })
			.ClientEvents(x => x.OnError("grid_onError"))
			.EnableCustomBinding(true))
</div>

<script type="text/javascript">
	function grid_onError(e) {
		alert(e.XMLHttpRequest.responseText);
		e.preventDefault();
	}
</script>